<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/4/27
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--解析表达式--%>
<%@ page isELIgnored="false" %>
<%--引入jstl--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--引入springMVC form--%>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="page" uri="/xianzhiOA/pageTag" %>
<%@ taglib prefix="p" uri="/xianzhiOA/powerTag" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>角色信息</title>
    <script type="application/javascript">
        function pToSub(page) {
            if(page!=undefined){
                var pageInp = document.getElementById("page");
                pageInp.value = page;
                var form = document.getElementById("roleForm");
                form.submit();
            }
        }
        function go(type) {
            var page = parseInt(document.getElementById("page").value);
            var pages = parseInt(document.getElementById("pages").value);
            if (type == 'a') {
                page = 1;
            } else if (type == 'b') {
                page = page - 2;
            } else if (type == 'c') {
                page = page - 1;
            } else if (type == 'd') {
                page = page + 1;
            } else if (type == 'e') {
                page = page + 2;
            } else if (type == 'f') {
                page = pages;
            }
            document.getElementById("page").value = page;
            document.getElementById("roleForm").action = "${pageContext.request.contextPath}/Role/selRoleAll.emp";
            document.getElementById("roleForm").submit();
        }
        function edit() {
            document.getElementById("roleForm").action = "${pageContext.request.contextPath}/Role/roleEdit.emp";
            document.getElementById("roleId").value = null;
            document.getElementById("roleForm").submit();
        }
    </script>
</head>
<body>
<!--头部开始-->
<jsp:include page="headerBack.jsp"></jsp:include>
<!-- 导航 -->
<jsp:include page="leftBack.jsp"></jsp:include>
<!--内容页-->
<div class="main">
    <!--内容页头部-->
    <div class="page-header">
        <div class="pull-left">
            <ol class="breadcrumb visible-sm visible-md visible-lg">
                <li><a href="${pageContext.request.contextPath}/Login/goHomePage"><i class="icon fa fa-home"></i>主页</a></li>
                <li class="active"><i class="fa fa-pencil"></i>基本信息</li>
            </ol>
        </div>
        <div class="pull-right">
            <h2>主页</h2>
        </div>
    </div>
    <sf:form id="roleForm" action="${pageContext.request.contextPath}/Role/selRoleAll.emp" modelAttribute="role" method="post" class="search1">
        <input type="hidden" id="page" name="page" value="${page}"/>
        <input type="hidden" id="pages" name='pages' value="${pages}"/>
        <sf:input path="roleId" type="hidden"/>
            <div style="height: 40px">
        <p:power jspPower="角色管理：添加">
                <button onclick="edit()" type="button" class="three btn btn-primary">添加</button>
        </p:power>
                <a href="${pageContext.request.contextPath}/Role/selRoleAll.emp" class="three btn btn-primary">重置</a>
            </div>
        <sf:input style="width: 150px" path="roleName" type="text" placeholder="按角色名称搜索..."/>
        <input style="width: 95px" class="sang_Calender" name="begin" type="text"
               value="<fmt:formatDate value="${begin}" pattern="yyyy-MM-dd" />"
               placeholder="创建后的时间">至
        <input style="width: 95px" class="sang_Calender" name="end" type="text"
               value="<fmt:formatDate value="${end}" pattern="yyyy-MM-dd" />"
               placeholder="创建前的时间">
        <button type="submit" class="one"><span class="fa fa-search"></span></button>
    </sf:form>
    <div class="well">
        <!--查询-->
        <table class="table" id="now">
            <thead>
            <tr>
                <th class="v">角色名称</th>
                <th class="v">创建时间</th>
                <p:power jspPower="角色管理：修改">
                <th class="vv">修改</th>
                </p:power>
                <p:power jspPower="角色管理：删除">
                <th class="vv">删除</th>
                </p:power>
                <p:power jspPower="角色管理：分配权限">
                    <th class="vv">分配权限</th>
                </p:power>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="p" items="${roleList}">
                <tr>
                    <td>${p.roleName}</td>
                    <td><fmt:formatDate type="both" value="${p.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                    <p:power jspPower="角色管理：修改">
                        <td>
                            <a href="${pageContext.request.contextPath}/Role/roleEdit.emp?id=${p.roleId}">
                                <i class="fa fa-pencil"></i></a>
                        </td>
                    </p:power>
                    <p:power jspPower="角色管理：删除">
                        <td>
                            <a href="${pageContext.request.contextPath}/Role/delete.emp?id=${p.roleId}">
                                <i class="fa fa-times"></i></a>&nbsp;
                        </td>
                    </p:power>

                    <p:power jspPower="角色管理：分配权限">
                        <td>
                            <a href="${pageContext.request.contextPath}/Role/goPowerAllotPage.emp?roleId=${p.roleId}"><i class="fa fa-cogs"></i></a>
                        </td>
                    </p:power>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
    <c:if test="${pages > 1}">
        <div style="float: right">
            <ul class="pagination">
                <page:paging length="10" page="${page}" pages="${pages}"/>
            </ul>
        </div>
    </c:if>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/dist/backEnd/js/datetime.js"></script>
</body>
</html>
